<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>

<div id="app">
    <h2>
        1：事件处理方法
    </h2>
    <button @click="say">Say {{msg}}</button>
    <!-- 如果传递多个参数，需要分开传递参数 -->
    <button @click="warn('hello',$event)">Say {{msg}}</button>

    <h2>
        2: 事件修饰符 单击事件继续传播
    </h2>
    <div @click="todo">
        <button @click="doThis">单击事件会继续传播，会触发上面的div的事件</button>
    </div>
    <br>
    <div @click="todo">
        <button @click.stop="doThis">阻断单击事件会继续传播</button>
    </div>
    <br>
    <a href="www.baidu.com" @click.stop.prevent="doStop">阻断事件的默认行为，阻断a标签的默认的href的行为</a>

    <button @click.once="doOnly">点击事件只会执行一次</button>

    <br>

    <input @keyup.enter="keyEnter"  value="按钮事件，当回撤之后，就会触发当前方法" />

</div>

<script src="node_modules/vue/dist/vue.js"></script>
<script>

    new Vue({
        el: '#app',
        data: {
            msg: 'hello msg'
        },
        methods: {
            say(enent) {

                alert(this.msg)
                // event 表示 原生的对象
                alert(event.target.innerHTML)
            },
            warn(hello, event) {
                alert(hello + "," + event.target.innerHTML)
            },
            todo() {
                alert("todo....");
            },
            doThis() {
                alert("toThis....");
            },
            doStop() {
                alert("doStop....");
            },
            doOnly() {
                alert("doOnly....");
            },
            keyEnter(){
                alert("keyEnter....");
            }
        }
    });
</script>
</body>
</html>
